package example.controller;

import example.common.Result;
import example.dto.SelectionAddDTO;
import example.dto.SelectionListDTO;
import example.service.ISelectionService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/selection")
public class SelectionController {

    @Resource
    private ISelectionService selectionService;

    @PostMapping("/list")
    public Result getSelection(@RequestBody SelectionListDTO selectionListDTO) {
        return selectionService.getSelection(selectionListDTO);
    }

    @PostMapping("/add")
    public Result addSelection(@RequestBody SelectionAddDTO selectionAddDTO) {
        return selectionService.addSelection(selectionAddDTO);
    }

    @PostMapping("/pdf")
    public Result uploadSelectionPdf(@RequestParam MultipartFile file, @RequestParam Long selectionId) {
        return selectionService.uploadSelectionPdf(file, selectionId);
    }

    @PostMapping("/dis")
    public Result disSelection(@RequestParam Long selectionId, @RequestParam List<String> departmentNames) {
        return selectionService.disSelection(selectionId, departmentNames);
    }

}
